//
// Created by hjie on 23-9-3.
//

#pragma once

#include <string>
#include <cstring>
#include <memory>
#include <functional>
#include <map>
#include <vector>
#include <rapidjson/document.h>

struct RequestHeaderProtocol
{
    std::string m_msg_type;
    std::string m_user_id;
    std::string m_room_id;
    int64_t m_timestamp;
};

struct ResponseHeaderProtocol
{
    std::string m_msg_type;
    std::string m_room_id;
    std::string m_user_id;
    std::string m_send_to_user_id;
    std::string m_timestamp;
    int m_policy;
    int m_result;
    // for target policy
    std::string m_from_user_id;
    std::string m_to_user_id;
};

class BaseProtocol
{
public:
    BaseProtocol();
    void MakeRequestHeaderProtocol();
    void MakeResponseHeaderProtocol();
    void MakeResponseHeaderProtocol(const std::string & msg_type, const std::string & room_id, int policy, int result = 0);
public:
    virtual void Dump(rapidjson::Document & output);
    virtual bool ParseData(rapidjson::Document & input);
public:
    void CopyFromRequestHeader(std::shared_ptr<BaseProtocol> & dst);
public:
    static std::shared_ptr<BaseProtocol> ParseHeaderData(rapidjson::Document & input);
public:
    std::shared_ptr<RequestHeaderProtocol> m_request_header;
    std::shared_ptr<ResponseHeaderProtocol> m_response_header;
public:
};



